package com.initialize.pub.generate.dao;

import com.initialize.pub.generate.pojo.Article;
import com.initialize.pub.generate.pojo.ArticleExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface ArticleMapper {
    @SelectProvider(type=ArticleSqlProvider.class, method="countByExample")
    long countByExample(ArticleExample example);

    @DeleteProvider(type=ArticleSqlProvider.class, method="deleteByExample")
    int deleteByExample(ArticleExample example);

    @Delete({
        "delete from article",
        "where aid = #{aid,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer aid);

    @Insert({
        "insert into article (aid, title, ",
        "classification, label, ",
        "release_time, update_time, ",
        "browse_the_number, thumb_up_number, ",
        "status, content)",
        "values (#{aid,jdbcType=INTEGER}, #{title,jdbcType=VARCHAR}, ",
        "#{classification,jdbcType=INTEGER}, #{label,jdbcType=VARCHAR}, ",
        "#{releaseTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, ",
        "#{browseTheNumber,jdbcType=INTEGER}, #{thumbUpNumber,jdbcType=INTEGER}, ",
        "#{status,jdbcType=INTEGER}, #{content,jdbcType=LONGVARCHAR})"
    })
    int insert(Article record);

    @InsertProvider(type=ArticleSqlProvider.class, method="insertSelective")
    int insertSelective(Article record);

    @SelectProvider(type=ArticleSqlProvider.class, method="selectByExampleWithBLOBs")
    @Results({
        @Result(column="aid", property="aid", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR),
        @Result(column="classification", property="classification", jdbcType=JdbcType.INTEGER),
        @Result(column="label", property="label", jdbcType=JdbcType.VARCHAR),
        @Result(column="release_time", property="releaseTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="browse_the_number", property="browseTheNumber", jdbcType=JdbcType.INTEGER),
        @Result(column="thumb_up_number", property="thumbUpNumber", jdbcType=JdbcType.INTEGER),
        @Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
        @Result(column="content", property="content", jdbcType=JdbcType.LONGVARCHAR)
    })
    List<Article> selectByExampleWithBLOBs(ArticleExample example);

    @SelectProvider(type=ArticleSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="aid", property="aid", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR),
        @Result(column="classification", property="classification", jdbcType=JdbcType.INTEGER),
        @Result(column="label", property="label", jdbcType=JdbcType.VARCHAR),
        @Result(column="release_time", property="releaseTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="browse_the_number", property="browseTheNumber", jdbcType=JdbcType.INTEGER),
        @Result(column="thumb_up_number", property="thumbUpNumber", jdbcType=JdbcType.INTEGER),
        @Result(column="status", property="status", jdbcType=JdbcType.INTEGER)
    })
    List<Article> selectByExample(ArticleExample example);

    @Select({
        "select",
        "aid, title, classification, label, release_time, update_time, browse_the_number, ",
        "thumb_up_number, status, content",
        "from article",
        "where aid = #{aid,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="aid", property="aid", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR),
        @Result(column="classification", property="classification", jdbcType=JdbcType.INTEGER),
        @Result(column="label", property="label", jdbcType=JdbcType.VARCHAR),
        @Result(column="release_time", property="releaseTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="browse_the_number", property="browseTheNumber", jdbcType=JdbcType.INTEGER),
        @Result(column="thumb_up_number", property="thumbUpNumber", jdbcType=JdbcType.INTEGER),
        @Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
        @Result(column="content", property="content", jdbcType=JdbcType.LONGVARCHAR)
    })
    Article selectByPrimaryKey(Integer aid);

    @UpdateProvider(type=ArticleSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Article record, @Param("example") ArticleExample example);

    @UpdateProvider(type=ArticleSqlProvider.class, method="updateByExampleWithBLOBs")
    int updateByExampleWithBLOBs(@Param("record") Article record, @Param("example") ArticleExample example);

    @UpdateProvider(type=ArticleSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") Article record, @Param("example") ArticleExample example);

    @UpdateProvider(type=ArticleSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Article record);

    @Update({
        "update article",
        "set title = #{title,jdbcType=VARCHAR},",
          "classification = #{classification,jdbcType=INTEGER},",
          "label = #{label,jdbcType=VARCHAR},",
          "release_time = #{releaseTime,jdbcType=TIMESTAMP},",
          "update_time = #{updateTime,jdbcType=TIMESTAMP},",
          "browse_the_number = #{browseTheNumber,jdbcType=INTEGER},",
          "thumb_up_number = #{thumbUpNumber,jdbcType=INTEGER},",
          "status = #{status,jdbcType=INTEGER},",
          "content = #{content,jdbcType=LONGVARCHAR}",
        "where aid = #{aid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKeyWithBLOBs(Article record);

    @Update({
        "update article",
        "set title = #{title,jdbcType=VARCHAR},",
          "classification = #{classification,jdbcType=INTEGER},",
          "label = #{label,jdbcType=VARCHAR},",
          "release_time = #{releaseTime,jdbcType=TIMESTAMP},",
          "update_time = #{updateTime,jdbcType=TIMESTAMP},",
          "browse_the_number = #{browseTheNumber,jdbcType=INTEGER},",
          "thumb_up_number = #{thumbUpNumber,jdbcType=INTEGER},",
          "status = #{status,jdbcType=INTEGER}",
        "where aid = #{aid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Article record);
}